package net.zjitc.servlet.response;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @Author Administrator
 * @Date 2020/5/21 14:34
 * 重定向：
 * 1、浏览器访问redirectDemo1
 * 2、redirectDemo1操作：
 *     重定向到redirectDemo2
 *     （响应码302，Location头——》简化成：sendRedirect()）
 **/
@WebServlet("/redirectDemo1")
public class RedirectDemo1 extends HttpServlet {
    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        /* 重定向到redirectDemo2
         * 响应码302，Location头——》简化成：sendRedirect()*/
        resp.sendRedirect("/web/redirectDemo2");
    }

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        this.doPost(req,resp);
    }
}
